{extend name="common/layout"}

{block name="body_tag_class"}{/block}

{block name="main"}
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">

            <input type="hidden" name="id" value="{$info.id}" />

            <div class="layui-form-item">
                <label class="layui-form-label">账号</label>
                <div class="layui-input-block">
                    <input type="text" name="account" value="{$info.account}" lay-verify="required" autocomplete="off"
                        placeholder="请输入账号" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="text" name="password" {if condition="$info.id eq '0' || $info.id eq ''" }
                        lay-verify="required" {/if} value="" autocomplete="off" placeholder="不更改留空" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <input type="radio" name="status" value="0" title="禁用" {if
                        condition="$info['status'] eq '0' or $info['status'] eq ''" } checked {/if}>
                    <input type="radio" name="status" value="1" title="启用" {if condition="$info['status'] eq '1'" }
                        checked {/if}>
                </div>
            </div>

            <div class="layui-form-item" pane="">
                <label class="layui-form-label">角色</label>
                <div class="layui-input-block">
                    {volist name='roleslist' id='vo' }
                    <input type="checkbox" name="roles[]" value="{$vo.id}" lay-skin="primary" title="{$vo.name}"
                        {$vo.ischeck}>
                    {/volist}
                </div>
            </div>

        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="webman-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="button" class="pear-btn pear-btn-sm" onclick="btnclose()">
                <i class="layui-icon layui-icon-close"></i>
                关闭
            </button>

        </div>
    </div>
</form>
{/block}

{block name="footer_script"}
<script>
    layui.use(['form', 'jquery'], function () {
        let form = layui.form;
        let $ = layui.jquery;

        form.on('submit(webman-save)', function (data) {
            $.ajax({
                url: '/admin/system/editAdmin',
                data: data.field,
                dataType: 'json',
                //contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.code == 1) {
                        layer.msg(result.msg, {
                            icon: 1,
                            time: 1000
                        }, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window
                                .name)); //关闭当前页
                            parent.layui.table.reload("webman-table");
                        });
                    } else {
                        layer.msg(result.msg, {
                            icon: 2,
                            time: 1000
                        });
                    }
                }
            })
            return false;
        });
    })

</script>
{/block}